This sample demonstrates how to create a Windows Store device app for a camera. A Windows Store device app is provided by an IHV or OEM to differentiate the capture experience for a particular camera. It can be used to adjust camera settings or to provide additional functionality or effects.
The Windows Store device app in this sample provides custom UI for adjusting camera settings when a specific camera associated with the app is being used to capture a photo or video. Device metadata is used to associate the app with a camera.
If the user launches this sample from the app tile in Start, rather than when the camera is capturing video, this sample simply displays a message.
Note This UI in this sample works together with the custom effect provided by the Driver MFT Sample. Build and install the Driver MFT Sample before running this sample, so that you can use the UI implemented in this device app to control the custom effect provided in the Driver MFT Sample.
This sample shows that a device app for camera can be activated in two different contexts. The context can be determined by examining the activation parameters.
-
The app can be activated from an attempt to adjust settings. This happens when an app calls Windows.Media.Capture.CameraOptionsUI.Show, or when the user taps the Camera options control followed by More options in the Camera Capture UI (Windows.Media.Capture.CameraCaptureUI). In this case, the activation parameter's kind property is Windows.ApplicationModel.Activation.ActivationKind.CameraSettings.
When this sample app is activated from the CameraSettings context, it provides a custom More options UI that contains slider and button controls to adjust camera settings. The camera settings are accessed using the VideoDeviceController object obtained from the activation event's CameraSettingsActivatedEventArgs argument. A Windows Store device app for a camera can also provide other additional settings not shown in this sample. For more info, see Windows Store device apps for cameras and the Driver MFT Sample sample.
-
The app can also be activated because the user chose the app tile in Start. In this case, the kind property is Windows.ApplicationModel.Activation.ActivationKind.Launched.
When a Windows Store device app for a camera is launched from the app tile in Start, it should provide an interesting and engaging experience. This experience can be used to highlight related products, provide customer support and other services. This sample simply shows an informational message in place of this experience.
Note The Camera Settings declaration must be included in package.appxmanifest. You can see how this is done by double-clicking on package.appxmanifest in Solution Explorer and opening the Declarations tab.
To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.
To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.
Related topics
- Concepts
- Windows Store device apps
- Windows Store device apps for cameras
- Samples
- Driver MFT Sample
- Camera Capture UI sample
- Camera Options UI sample
- Tutorials
- Quickstart: Capturing a photo or video using the camera dialog
- Reference
- Windows.Media.Capture.CameraCaptureUI
- Windows.Media.Capture.CameraOptionsUI
Operating system requirements
| Client | |
|---|---|
| Server |
Build the sample
Prerequisites
The Windows Store device app that this sample demonstrates must be linked to your camera using device metadata.
-
You need a copy of the device metadata package for your camera, to add the device app info to it. If you don’t have device metadata, you can build it using the Device Metadata Authoring Wizard as described in the topic Step 2: Create device metadata for your Windows Store device app.
Note To use the Device Metadata Authoring Wizard, you must install the standalone SDK for Windows 8.1 before completing the steps in this topic. Installing Microsoft Visual Studio Express 2013 for Windows installs a version of the SDK that doesn't include the wizard.
- If you have an internally embedded camera, rather than an externally connected one, follow the requirements that apply to your camera, described in “Appendix A: Requirements for identifying internal cameras” in the paper Developing Windows Store device apps for Cameras. For more info, see Windows Store device apps for cameras.
Install the sample
The following steps build the sample and install device metadata.
- Enable test signing.
- Start the Device Metadata Authoring Wizard from %ProgramFiles(x86)%\Windows Kits\8.1\bin\x86, by double-clicking DeviceMetadataWizard.exe
- From the Tools menu, select Enable Test Signing.
- Reboot the computer
-
Build the solution by opening the solution (.sln) file titled DeviceAppForWebcam.sln. Press F7 or go to Build->Build Solution from the top menu after the sample has loaded.
- Disconnect and uninstall the camera. This step is required so that Windows will read the updated device metadata the next time the device is detected.
- If you have an externally connected camera, disconnect and uninstall your camera.
- If you have an internal camera, use Device Manager to uninstall the camera.
- Edit and save device metadata. To link the device app to your camera, you must associate the device app with your camera.
Note If you haven't created your device metadata yet, see Step 2: Create device metadata for your Windows Store device app.
- If the Device Metadata Authoring Wizard is not open yet, start it from %ProgramFiles(x86)%\Windows Kits\8.1\bin\x86, by double-clicking DeviceMetadataWizard.exe.
- Click Edit Device Metadata. This will let you edit your existing device metadata package.
- In the Open dialog box, locate the device metadata package associated with your Windows Store device app. (It has a devicemetadata-ms file extension.)
- On the Specify Windows Store device app information page, enter the Windows Store app info in the Windows Store device app box. Click on Import Windows Store App manifest file to automatically enter the Package name, Publisher name, and Windows Store App ID.
- When you're done, click Next until you get to the Finish page.
- On the Review the device metadata package page, make sure that all of the settings are correct and select the Copy the device metadata package to the metadata store on the local computer check box. Then click Save.
- Reconnect your camera so that Windows reads the updated device metadata when the device is connected.
- If you have an external camera, simply connect the camera.
- If you have an internal camera, do one of the following:
- Refresh the PC in the Devices and Printers folder.
- Use Device Manager to scan for hardware changes. Windows should read the updated metadata when the device is detected.
Run the sample
To run the sample as if it were launched by the user choosing the app tile in Start, press F5 (run with debugging enabled) or Ctrl+F5 (run without debugging enabled), or select the corresponding options from the Debug menu.
To run the custom user interface for More options, do the following:
- Build and install the Driver MFT Sample, to install a custom effect that the More options flyout can control. You may skip this step, but then the Effect On/Off and Effect controls in the custom flyout will not work.
- Run an app that invokes the More options flyout. Here are two ways to do that:
- Run an app that displays the Camera Capture UI using
Windows.Media.Capture.CameraCaptureUI. The
Camera Capture UI sample is an example of such an app.
Quickstart: Capturing a photo or video using the camera dialog provides a tutorial on using the Camera Capture UI.
When the Camera Capture UI is displayed, tap the options button and then choose More options in the dialog box that appears.
- Run an app that calls CameraOptionsUI.Show. The Camera Options UI sample is an example of such an app.
- Run an app that displays the Camera Capture UI using
Windows.Media.Capture.CameraCaptureUI. The
Camera Capture UI sample is an example of such an app.
Quickstart: Capturing a photo or video using the camera dialog provides a tutorial on using the Camera Capture UI.
- Check if the custom More options UI is correctly installed. It should contain Effect On/Off and Effect controls. If you don't see these controls, check the troubleshooting steps.
- If you installed the Driver MFT Sample in step 1, the Effect On/Off control toggles an effect that covers the lower part of the video with a green box. The Effect control adjusts the amount of the video that is covered.
Troubleshooting
If the More options flyout doesn't contain Effect On/Off and Effect controls, check the following:
- Make sure you enabled test signing before installing the sample. Enable test signing by running
bcdedit -set testsigning onin a command prompt. - Make sure Package Name, Publisher Name, and App ID in the device metadata match the fields defined in the package.appxmanifest file of this sample.
- Use the Camera Capture UI sample to test.
- If you have an internal camera (rather than an externally connected one), follow the requirements for your camera described in "Appendix A: Requirements for identifying internal cameras" in the Developing device apps for Cameras white paper. Note that you don’t have to provide the PLD information described in the paper, if your camera does not expose PLD info in its ACPI tables.
- If you have an internal camera, after installing the sample, refresh the PC using the Devices and Printers folder. Select the PC in the folder, and click the Refresh button as shown in the following image. The camera itself should not be visible in the Devices and Printers folder. This is because internal cameras are enumerated as part of the PC device container.
If you have installed the Driver MFT Sample but don't see the video effect that covers the lower part of the video with a green box, check the following:
- Check that the Effect On/Off switch in the More Options flyout is set to On.
- Check that the SampleMFT0.DLL is registered and that you have entered the CLSID of the Driver MFT under the device registry key for the camera you are using to capture video, as described in Building the sample.
- Check that SampleMFT0.DLL is in a subdirectory of Program Files.